import 'package:FiduMart/generated/json/base/json_convert_content.dart';
import 'package:FiduMart/core/network/model/DRN_withdrawalRecord_entity.dart';

DRNWithdrawalRecordEntity $DRNWithdrawalRecordEntityFromJson(
    Map<String, dynamic> json) {
  final DRNWithdrawalRecordEntity dRNWithdrawalRecordEntity = DRNWithdrawalRecordEntity();
  final List<DRNWithdrawalRecordList>? list = (json['list'] as List<dynamic>?)
      ?.map(
          (e) =>
      jsonConvert.convert<DRNWithdrawalRecordList>(
          e) as DRNWithdrawalRecordList)
      .toList();
  if (list != null) {
    dRNWithdrawalRecordEntity.list = list;
  }
  final int? page = jsonConvert.convert<int>(json['page']);
  if (page != null) {
    dRNWithdrawalRecordEntity.page = page;
  }
  final int? pageSize = jsonConvert.convert<int>(json['pageSize']);
  if (pageSize != null) {
    dRNWithdrawalRecordEntity.pageSize = pageSize;
  }
  final int? total = jsonConvert.convert<int>(json['total']);
  if (total != null) {
    dRNWithdrawalRecordEntity.total = total;
  }
  return dRNWithdrawalRecordEntity;
}

Map<String, dynamic> $DRNWithdrawalRecordEntityToJson(
    DRNWithdrawalRecordEntity entity) {
  final Map<String, dynamic> data = <String, dynamic>{};
  data['list'] = entity.list?.map((v) => v.toJson()).toList();
  data['page'] = entity.page;
  data['pageSize'] = entity.pageSize;
  data['total'] = entity.total;
  return data;
}

extension DRNWithdrawalRecordEntityExt on DRNWithdrawalRecordEntity {
  DRNWithdrawalRecordEntity copyWith({
    List<DRNWithdrawalRecordList>? list,
    int? page,
    int? pageSize,
    int? total,
  }) {
    return DRNWithdrawalRecordEntity()
      ..list = list ?? this.list
      ..page = page ?? this.page
      ..pageSize = pageSize ?? this.pageSize
      ..total = total ?? this.total;
  }
}

DRNWithdrawalRecordList $DRNWithdrawalRecordListFromJson(
    Map<String, dynamic> json) {
  final DRNWithdrawalRecordList dRNWithdrawalRecordList = DRNWithdrawalRecordList();
  final String? id = jsonConvert.convert<String>(json['id']);
  if (id != null) {
    dRNWithdrawalRecordList.id = id;
  }
  final int? state = jsonConvert.convert<int>(json['state']);
  if (state != null) {
    dRNWithdrawalRecordList.state = state;
  }
  final String? stateName = jsonConvert.convert<String>(json['stateName']);
  if (stateName != null) {
    dRNWithdrawalRecordList.stateName = stateName;
  }
  final int? createdAt = jsonConvert.convert<int>(json['createdAt']);
  if (createdAt != null) {
    dRNWithdrawalRecordList.createdAt = createdAt;
  }
  final double? amount = jsonConvert.convert<double>(json['amount']);
  if (amount != null) {
    dRNWithdrawalRecordList.amount = amount;
  }
  final double? feeRate = jsonConvert.convert<double>(json['feeRate']);
  if (feeRate != null) {
    dRNWithdrawalRecordList.feeRate = feeRate;
  }
  final int? fee = jsonConvert.convert<int>(json['fee']);
  if (fee != null) {
    dRNWithdrawalRecordList.fee = fee;
  }
  final double? actualAmount = jsonConvert.convert<double>(
      json['actualAmount']);
  if (actualAmount != null) {
    dRNWithdrawalRecordList.actualAmount = actualAmount;
  }
  final String? remark = jsonConvert.convert<String>(json['remark']);
  if (remark != null) {
    dRNWithdrawalRecordList.remark = remark;
  }
  final String? address = jsonConvert.convert<String>(json['address']);
  if (address != null) {
    dRNWithdrawalRecordList.address = address;
  }
  final String? net = jsonConvert.convert<String>(json['net']);
  if (net != null) {
    dRNWithdrawalRecordList.net = net;
  }
  return dRNWithdrawalRecordList;
}

Map<String, dynamic> $DRNWithdrawalRecordListToJson(
    DRNWithdrawalRecordList entity) {
  final Map<String, dynamic> data = <String, dynamic>{};
  data['id'] = entity.id;
  data['state'] = entity.state;
  data['stateName'] = entity.stateName;
  data['createdAt'] = entity.createdAt;
  data['amount'] = entity.amount;
  data['feeRate'] = entity.feeRate;
  data['fee'] = entity.fee;
  data['actualAmount'] = entity.actualAmount;
  data['remark'] = entity.remark;
  data['address'] = entity.address;
  data['net'] = entity.net;
  return data;
}

extension DRNWithdrawalRecordListExt on DRNWithdrawalRecordList {
  DRNWithdrawalRecordList copyWith({
    String? id,
    int? state,
    String? stateName,
    int? createdAt,
    double? amount,
    double? feeRate,
    int? fee,
    double? actualAmount,
    String? remark,
    String? address,
    String? net,
  }) {
    return DRNWithdrawalRecordList()
      ..id = id ?? this.id
      ..state = state ?? this.state
      ..stateName = stateName ?? this.stateName
      ..createdAt = createdAt ?? this.createdAt
      ..amount = amount ?? this.amount
      ..feeRate = feeRate ?? this.feeRate
      ..fee = fee ?? this.fee
      ..actualAmount = actualAmount ?? this.actualAmount
      ..remark = remark ?? this.remark
      ..address = address ?? this.address
      ..net = net ?? this.net;
  }
}